package com.smart.controller;

import com.smart.common.WebResponse;
import com.smart.common.annotation.WebAccess;
import com.smart.model.request.ProjectRequest;
import com.smart.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;

/**
 * @author: zyh
 * @date: 2023-06-27
 */
@RestController
@RequestMapping("/manageProject")
@Api(value = "云管理模块", tags = {"云管理平台#项目管理模块"})
public class CloudMaProjectController {
    @Autowired
    private ProjectService projectService;

    @WebAccess(login = true)
    @ApiOperation("项目管理列表查询")
    @PostMapping("/selectMaProjectList")
    public WebResponse selectMaProjectList(@SortDefault(sort = "p.create_time",direction = Sort.Direction.DESC) Pageable pageable,
                                            @RequestBody ProjectRequest request) {
        return WebResponse.build(projectService.selectMaProjectList(request,pageable));
    }

    @WebAccess(login = true)
    @ApiOperation("项目详情查询")
    @GetMapping("/selectMaProjectDetail/{id}")
    public WebResponse selectMaProjectDetail(@PathVariable("id")Long id) {
        return WebResponse.build(projectService.selectMaProjectDetail(id));
    }
}
